<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<BusinessTransactionResponse>
			<xsl:for-each select="insupost-response">
				<BusinessTransaction>
					<kind>Surrender</kind>
					<transationId>
						<xsl:value-of select="response-head/trans-id" />
					</transationId>
					<transationDate>
						<xsl:value-of select="concat(substring(string(response-head/trans-date),1,4),'-',substring(string(response-head/trans-date),5,2),'-',substring(string(response-head/trans-date),7,2),' ',substring(string(response-head/trans-time),1,2),':',substring(string(response-head/trans-time),3,2),':',substring(string(response-head/trans-time),5,2))" />
					</transationDate>
					<partnerCode>WANGXIAO</partnerCode>
					<applyCode>
						<xsl:value-of select="response-head/column2" />
					</applyCode>
					<xsl:choose>
						<xsl:when test="/insupost-response/response-head/trans-result = 0">
							<xsl:for-each select="response-intraday-cancel/endorsement-print">
								<Properties>
									<Property kind="transactionAmount" name="实际退保金额">
										<xsl:attribute name="value"><xsl:value-of select="policy-info/column1" /></xsl:attribute>
									</Property>
									<Property kind="availableMoney" name="可支取支取金额">
										<xsl:attribute name="value"><xsl:value-of select="policy-info/column1" /></xsl:attribute>
									</Property>
									<Property kind="serviceCharge" name="手续费">
										<xsl:attribute name="value"><xsl:value-of select="policy-info/column2" /></xsl:attribute>
									</Property>
								</Properties>
							</xsl:for-each>
						</xsl:when>
					</xsl:choose>
				</BusinessTransaction>
				<TransactionResult>
					<xsl:choose>
						<xsl:when test="/insupost-response/response-head/trans-result = 1">
							<resultCode>SUCCESS</resultCode>
						</xsl:when>
						<xsl:when test="/insupost-response/response-head/trans-result = 2">
							<resultCode>RESPONSE_PENDING</resultCode>
						</xsl:when>
						<xsl:otherwise>
							<resultCode>FAILURE</resultCode>
						</xsl:otherwise>
					</xsl:choose>
					<approveStatus>
						<xsl:value-of select="/insupost-response/response-head/column3" />
					</approveStatus>
					<ResultInfo>
						<xsl:choose>
							<xsl:when test="response-intraday-cancel/errors != ''">
								<xsl:for-each select="response-intraday-cancel/errors">
									<infoCode>
										<xsl:value-of select="error/error-code" />
									</infoCode>
									<infoCodeMessage>
										<xsl:value-of select="error/error-desc" />
									</infoCodeMessage>
								</xsl:for-each>
							</xsl:when>
						</xsl:choose>
						<xsl:choose>
							<xsl:when test="response-head/validity-errors != ''">
								<xsl:for-each select="response-head/validity-errors">
									<infoCode>
										<xsl:value-of select="validity-error/error-code" />
									</infoCode>
									<infoCodeMessage>
										<xsl:value-of select="validity-error/error-desc" />
									</infoCodeMessage>
								</xsl:for-each>
							</xsl:when>
						</xsl:choose>
					</ResultInfo>
				</TransactionResult>
				<xsl:choose>
					<xsl:when test="/insupost-response/response-head/trans-result = 0">
						<InsurancePolicy>
							<xsl:for-each select="response-intraday-cancel/endorsement-print">
								<externalReference>
									<xsl:value-of select="policy-info/policy-code" />
								</externalReference>
								<Properties>
									<Property kind="policyStatus" name="保单状态" value="CANCELLED" />
									<Property kind="policyValue" name="保单价值" value="0"></Property>
								</Properties>
							</xsl:for-each>
						</InsurancePolicy>
					</xsl:when>
					<xsl:when test="/insupost-response/response-head/trans-result = 2">
						<InsurancePolicy>
							<xsl:for-each select="response-intraday-cancel/endorsement-print">
								<externalReference>
									<xsl:value-of select="policy-info/policy-code" />
								</externalReference>
								<Properties>
									<Property kind="policyStatus" name="保单状态" value="CANCELLED" />
									<Property kind="policyValue" name="保单价值" value="0"></Property>
								</Properties>
							</xsl:for-each>
						</InsurancePolicy>
					</xsl:when>
				</xsl:choose>
			</xsl:for-each>
		</BusinessTransactionResponse>
	</xsl:template>
</xsl:stylesheet>
